This folder contains the codes and datasets used in paper: Optimal Regularized Online Allocation by Adaptive Re-Solving (July 2023)

********
To reproduce figures in the paper, Gurobi license is needed, together with other used libraries in the python file (e.g., pandas, cvxpy, numpy, etc.). Contact ycaoan@connect.ust.hk if any problems.
********

******** Per-Step Execution Time Record:
- OGD: O(1)
- Alg2 with K=t (Nonadaptive / Adaptive): O(n)
- Alg2 with K=t^2 (Nonadaptive / Adaptive): O(n^2)
- Infreq: O(log(n))
- Fast: O(1)


**** Input I:

- Data collection
To collect one data point at T -> Modify n=T in file input I.py and run it.

After collecting data points at T={256, 512, 1024, 1536, 2048, 2560}

- Draw Figure 2: run regret-input-i.py with T={256, 512, 1024, 1536, 2048, 2560} or any set of data points you've collected.

- Draw Figure 3: run remaining-level-input-i.py with the file name replaced by the data point you want to study. It was T=512 in the paper.


**** Input II:

- Data collection
To collect one data point at T -> Modify n=T in file input II.py and run it.

After collecting data points at T={256, 512, 1024, 1536, 2048, 2560}

- Draw Figure 4: run regret-input-ii.py with T={256, 512, 1024, 1536, 2048, 2560} or any set of data points you've collected.

- Draw Figure 5: run remaining-level-input-ii.py with the file name replaced by the data point you want to study. It was T=512 in the paper.


**** Input III:

- Data collection
To collect datapoints -> Modify T = "the set of interest" in file input III.py and run it. In the paper, T = {3, 33, 63, 93, 123, ... , 603, 1024, 2048}.

- Draw Figure 6:

a. Average regret: run regret-input-iii.py with T (consistent with the set T specified in inputIII.py)

b. Remaining time: run remainingTime-input-iii.py with T (consistent with the set T specified in inputIII.py)


**** Input IV:
- Data collection: Modify nrange = "the set of interest" in input_IV.py (line 444), and run it with "labda = 0, 0.01, 0.1" (line 445). In the paper, nrange = [16, 32, 64, 128, 256, 512, 768, 1024]

- Figure 7:
a,b,c. Run regret-input-iv.py with labda = 0, 0.01, 0.1 and T = "the set of interest" (consistent with nrange in input_IV.py)

d. per-step reward w.r.t. \kappa: run tradeoff-input-iv.py (data point T = 1024 is needed, or modify T = the data point of interest)




 